<%@ page language="java" import="java.util.*" import="java.sql.*" import="orm.*" pageEncoding="utf-8" errorPage="errorPage.jsp"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@  page import ="org.apache.struts.util.LabelValueBean"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<%
    String testName = ((Test)session.getAttribute("test")).getTestname();
    int[] score = (int[])session.getAttribute("score");
%>

<html>
<head>
<base href = <%=basePath%> />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>考试</title>
<link href="css/mainStyles.css" rel="stylesheet" type="text/css" />
<style>
#container {
	height: 825px;
	outline: double;
	outline-color: #666;
	color: #000000;
}
#top {
	outline: double;
	outline-color: #666;
}
#side {
	width: 256px;
	height: 600px;
	border-right:1px solid #666;
}
#title {
	width: 768px;
	height: 100px;
	position: relative;
	left: 256px;
	top: -600px;
	font-family: "华文新魏";
	font-size: 36px;
	color: #000000;
	text-align:center;
}
#testPaper {
	width: 768px;
	height: 500px;
	position: relative;
	left: 256px;
	top: -600px;
}
#time {
	font-size: 24px;
}
#help {
	font-size: 22px;
}
#testPaperFrame {
	position:relative;
	left:10px;
	top:10px;
}

</style>

 <script language="javascript" src="js/AjaxRequest.js">
</script>
<script language="javascript">
    var timer = window.setInterval("showStartTime();showRemainTime();",1000); 
    function showStartTime(){
	    var loader=new net.AjaxRequest("startexam.do?action=showStartTime&nocache="+new Date().getTime(),deal_s,onerror,"GET");
    }
    function showRemainTime(){
	    var loader1=new net.AjaxRequest("startexam.do?action=showRemainTime&nocache="+new Date().getTime(),deal_r,onerror,"GET");
    }

    function onerror(){
    }
    function deal_s(){
	    showStartTimediv.innerHTML=this.req.responseText;
    }
    function deal_r(){
     	showRemainTimediv.innerHTML=this.req.responseText;
	    if(this.req.responseText.indexOf("00:00:00") != -1){
	    	window.clearInterval(timer);
		    this.testPaperFrame.document.testResult.submit();
	    }
     }
</script>
<script language="javascript">
	function commit(){
		window.clearInterval(timer);
		this.testPaperFrame.document.testResult.submit();
		document.getElementById("submitT").disabled = "disabled";
	}
</script>
<script language=javascript>
    function keydown(){
	   if(event.keyCode==8){
		    event.keyCode=0;
		    event.returnValue=false;
		    alert("当前考试不允许使用退格键");
	    }if(event.keyCode==13){
		    event.keyCode=0;
		    event.returnValue=false;
		    alert("当前考试不允许使用回车键");
	    }if(event.keyCode==116){
		    event.keyCode=0;
		    event.returnValue=false;
		    alert("当前考试不允许使用F5刷新键");
	    }if((event.altKey)&&((window.event.keyCode==37)||(window.event.keyCode==39))){
		   event.returnValue=false;
		   alert("当前考试不允许使用Alt+方向键←或方向键→");
	    }if((event.ctrlKey)&&(event.keyCode==78)){
	       event.returnValue=false;
	       alert("当前考试不允许使用Ctrl+n新建IE窗口");
	    }if((event.shiftKey)&&(event.keyCode==121)){
	       event.returnValue=false;
	       alert("当前考试不允许使用shift+F10");
	     }if(event.keyCode==27){
		    event.keyCode=0;
		    event.returnValue=false;
		    alert("当前考试不允许使用Esc键");
           }
      }
     function click() {
         event.returnValue=false;
	     alert("当前设置不允许使用右键！");
      }
     document.oncontextmenu=click;
  </script>


</head>

<body onLoad="showStartTime();showRemainTime();" onkeydown="keydown()" >
 
	<div id = "container">
    	<div id = "top">
        </div>
    	<div id = "side">
        	<div id = "time">
        		<center>
            	<br /><br />
            	剩余时间：<div id="showRemainTimediv" style="color:#F00;"></div>
                                           已用时间：<div id="showStartTimediv"></div>
                <br />
                <hr />
                </center>
            </div>
            <div id = "help">
            	<center>
                	<p><a href="startexam.do?action=exit">退出考试</a></p>
                	<p><button type="button" value="交卷？" name="submit" id="submitT" onclick="commit();"
                	 style="size:40px; height:30px; width:70px; font-size: 24px;">交卷</button></p>
                    <p><strong>在线帮助</strong></p>
                    <select name="help" size="10">
                    	<option value="1">1.考试指南</option>
                        <option value="2">2.考场规则</option>
                        <option value="3">3.在线帮助</option>
                    </select>
                    <p><button type="button" value="寻求帮助？" name="commit">寻求帮助？</button></p>
                </center>
            </div>
        </div>
        <div id = "title">
        <br />
        	<%=testName %>
        	    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="50%">&nbsp;</td>
                  <td width="50%" style="color:#000000;">&nbsp;满分<font color="red"><%=String.valueOf(score[3]) %>
                  </font>分&nbsp;&nbsp;&nbsp;单选题<font color="red"><%=String.valueOf(score[0]) %>
                  </font>分&nbsp;&nbsp;&nbsp;多选题<font color="red"><%=String.valueOf(score[1]) %>
                  </font>分&nbsp;&nbsp;&nbsp;主观题<font color="red"><%=String.valueOf(score[2]) %></font>分</td>
                 </tr>
                </table>
            <hr />
        </div>
        

        
        <div id = "testPaper">
        <iframe src="student/testPaper.jsp" height="480" width="748" frameborder="0"
            		marginheight="0" marginwidth="0" id="testPaperFrame" name="testPaperFrame"></iframe>
        
        </div>
    </div>
</body>
</html>
